package team.you.change.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import team.you.change.pojo.Class;
import team.you.change.util.Result;
import team.you.change.service.ClassService;

import javax.annotation.Resource;

@Controller
@RequestMapping("/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    @RequestMapping("/getAllClasses")
    @ResponseBody
    private Result getAllClasses(Integer page, Integer limit)
    {
        return classService.getAllClasses(page,limit);
    }
    @RequestMapping("/del")
    @ResponseBody
    private Result del(String id)
    {
        return classService.del(id);
    }
    @RequestMapping("/delete")
    @ResponseBody
    private Result delete(String[] ids)
    {
        return classService.delete(ids);
    }
    @RequestMapping("/update")
    @ResponseBody
    private Result update(Class clas)
    {
        return classService.update(clas);
    }
    @RequestMapping("/add")
    @ResponseBody
    private Result add(Class clas){
        return classService.add(clas);
    }
    @RequestMapping("/selectByLike")
    @ResponseBody
    private Result selectByLike(String value, Integer college, Integer major, Integer page, Integer limit){
        return classService.selectByLike(value, college == null ? 0:college, major == null ? 0:major, page, limit);
    }
    @RequestMapping("/selCode")
    @ResponseBody
    private Result selCode(String code){
        return classService.selCode(code);
    }
    @RequestMapping("/getClassOption")
    @ResponseBody
    private Result getClassOption(){
        return classService.getClassOption();
    }
}
